package cc.xsubj.trading.inventory;

public class ItemStack
{
    private int quantity;
    private ItemType type;
    
    public ItemStack(ItemType type, int quantity)
    {
        if (quantity < 1)
            quantity = 1;
        this.setQuantity(quantity);
        this.setType(type);
    }
    
    public ItemStack(int itemID, int quantity)
    {
        this.setType(ItemRegistry.getItemByID(itemID));
        if (quantity < 1)
            quantity = 1;
        this.setQuantity(quantity);
    }
    

    public int getQuantity()
    {
        return quantity;
    }

    public void setQuantity(int quantity)
    {
        this.quantity = quantity;
    }

    public ItemType getType()
    {
        return type;
    }

    public void setType(ItemType type)
    {
        this.type = type;
    }
    
    public String getName()
    {
        return type.name;
    }
    
    public void increaseQuantity(int amount)
    {
        quantity += amount;
    }
    
    public boolean decreaseQuantity(int amount)
    {
        if (amount > quantity)
            return false;
        quantity -= amount;
        return true;
    }
}
